//http://115.28.203.224/problem.php?cid=1014&pid=0





#include<stdio.h>
long long int a[100005][3]={0};
 int main (){
 	int t,n,m,i0,i,j,flog=0;
 	long long int key; 
 	scanf("%d",&t);
 	for(;t>0;t--){
 		scanf("%d%d",&n,&m);
 		for(i=1;i<=n;i++){
 			scanf("%d%d",&a[i][1],&a[i][2]);
 			a[i][3]=a[i][1]*a[i][2];
		 }
		for(i0=1;i0<=m;i0++){
		 	scanf("%d",&j);
		 	for(i=1;i<=n;i++){
		 		if(j<=a[i][1]){
		 			key=a[i-1][2]*j;
		 			flog=1;
		 			break;}
		 		if(!flog)
					key=a[i-1][2]*j;
			} 
		 			
			for(;i<=n;i++){ 
				if(key>a[i][3])
					key=a[i][3];
			}
			printf("%lld ",key);
		}
			printf("\n"); 
 		
	}
}